﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using RootFinding;

namespace Zove.Desktop {
    public partial class RootFinderForm : Form, IDesktopForm {
        public RootFinderForm() {
            InitializeComponent();
        }

        public void Execute() {
            if (string.IsNullOrEmpty(this.tbEquation.Text)) {
                return;
            }

            try {
                IRootFinder rootFinder = new SimpleRootFinder();
                double result = rootFinder.Solve(this.tbEquation.Text, 0, double.MaxValue);

                MessageBox.Show(result.ToString());
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }

        #region IDesktopForm Members
        
        public DigitalRune.Windows.TextEditor.TextEditorControl GetTextEditorControl() {
            throw new NotImplementedException();
        }

        public string GetFileName() {
            throw new NotImplementedException();
        }

        public string GetFileExtension() {
            throw new NotImplementedException();
        }

        public void Export(string fileName) {
            throw new NotImplementedException();
        }

        public void Save(string fileName) {
            throw new NotImplementedException();
        }

        public string GetFileFilter() {
            throw new NotImplementedException();
        }

        public virtual string GetColouringScheme() {
            return string.Empty;
        }

        #endregion
    }
}
